package com.youlu.campus.web.community.controller;

import com.youlu.campus.entity.VO.req.DouYinActivityUserSignUpInfoCommand;
import com.youlu.campus.service.douyin.ActivityDouYinService;
import com.youlu.campus.service.douyin.DouYinUserWatchVideoService;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class DouYinController {

    @Autowired
    private ActivityDouYinService activityDouYinService;

    @Autowired
    private DouYinUserWatchVideoService douYinUserWatchVideoService;


    @GetMapping("/mini-app/douyin/activity/sign-up")
    public QResult  douYinActivitySignUp(String activityId) {
        return QResult.success(activityDouYinService.getSignUpUserInfo(RequestContext.getCurUser(), activityId));
    }

    /**
     * 更新报名用户信息
     * @param
     * @return
     */
    @PostMapping("/mini-app/douyin/sign-up/user/update")
    public QResult updateDouYinActivitySignUp(@RequestBody DouYinActivityUserSignUpInfoCommand command) {
        command.setCurrentUser(RequestContext.getCurUser());
        activityDouYinService.updateDouYinActivitySignUp(command);
        return QResult.success(null);
    }

    @PutMapping("/mini-app/douyin/video/watch/{activityId}")
    public QResult  douYinWatch(@PathVariable String activityId) {
        return QResult.success(douYinUserWatchVideoService.findByActivityId(activityId,RequestContext.getCurUser()));
    }

    @GetMapping("/mini-app/douyin/video/user-watch")
    public QResult  douYinWatchVideo(String activityId) {
        return QResult.success(douYinUserWatchVideoService.watchVideoByActivityId(activityId,RequestContext.getCurUser()));
    }

}
